package 区间K倍;

import java.util.Scanner;

public class Main {
    static int N = 100010;
    static long[] s = new long[N];
    static int[] cnt = new int[N];

    public static void main(String[] args) {
        Scanner in = new Scanner(System.in);
        int n = in.nextInt();
        int k = in.nextInt();
        for (int i = 1; i <= n; i++) {
            s[i] = in.nextInt();
            s[i] += s[i - 1];
        }
        long res = 0;
        cnt[0]++;
        for (int i = 1; i <= n; i++) {
            res += cnt[(int) (s[i] % k)];
            cnt[(int) (s[i] % k)]++;
        }
        System.out.println(res);
    }
}
